<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<link rel="stylesheet" type="text/css" href="/css/business.css"/>

<script type="text/javascript">
$(document).ready(function(){
	$("#searchKeyword").keydown(function(evt){
		var keyword = $("#searchKeyword").val();
		if(evt.keyCode == 13){
			if(keyword == ''){
				alert("검색어를 입력하세요.");
				return false;
			}else{
				//alert("11");
				$("#bizForm").attr('action','/biz/bizListForUser.desk').submit();
			}
		}
	});
	
	//$("select[name='order']").change(function(){
	$("#orderBy").change(function(){
		$("#bizForm").attr('action','/biz/bizListForUser.desk').submit();
	});

	$("select[name='deskCode']").change(function(){
		var deskCode = $(this).find("option:selected").val();
		//alert(deskCode);
		location.href = "/biz/bizListForUser.desk?deskCode=" + deskCode;
	});
});
</script>
<script type="text/javascript" language="javascript" src="/js/ga.js"></script>

<s:url id="bizListURLPrev" value="/biz/bizListForUser.desk">
	<s:param name="userSeq">
		<s:property value="#session.userSeq"/>
	</s:param>
	<s:param name="pageNumber">
		<s:property value="pageInfoDataMap.pageNumber - 1"/>
	</s:param>
</s:url>

<s:url id="bizListURLNext" value="/biz/bizListForUser.desk">
	<s:param name="userSeq">
		<s:property value="#session.userSeq"/>
	</s:param>
	<s:param name="pageNumber">
		<s:property value="pageInfoDataMap.pageNumber + 1"/>
	</s:param>
	<s:param name="deskCode">
		<s:property value="deskCode"/>
	</s:param>
</s:url>

<s:set name="currentPageNumber" value="pageNumber"/>

<s:set name="totalCount" value="%{totalCount}"/>
<s:set name="authCode" value="%{pageInfoDataMap.authCode}"/>



<form name="bizForm" id="bizForm" method="post">
<input type="hidden" name="userSeq" value="<s:property value="#session.userSeq"/>"/>
<input type="hidden" name="authCode" value="<s:property value="#session.authCode"/>"/>
<input type="hidden" name="deskCodeForExcel" value="<s:property value="#session.deskCode"/>"/>
<input type="hidden" name="reportGubun" value="biz"/>

<div id="wrap">
  <dl class="SubContents_Tit">
    <dd><img src="/images/business/SubContents_Tit_01.gif" width="370" height="42" alt="기업정보 관리" /></dd>
    <dd><img src="/images/business/SubTit_01.gif" width="140" height="30" alt="기업 정보 목록" /></dd>
  </dl>
  <dl class="SubContents_Contents_Search">
    <!-- 센터 선택 -->
    <dd><img src="/images/business/Sub_CenterChoice.gif" width="82" height="21" alt="센터 선택" /></dd>
    <dd>
      <s:if test="#authCode == 'ADMIN'">	
        	<s:include value="/view/include/common/deskcode/deskcode_total.jsp"/>
   	  </s:if>
   	  <s:if test="#authCode != 'ADMIN'">
   			<span style="font-weight: bold; color: blue;"><s:property value="#session.deskCodeValue"/></span>
   	  </s:if>
   		
    </dd>
  </dl>
  <!-- 센터 선택 -->
  <dl class="SubContents_Contents_Search">
    <dd>총 <span class="TEXT_Red_Bold"><s:property value="#totalCount"/></span>건의 상담일지 정보 검색됨</dd>
  </dl>
  <dl class="SubContents_Search">
    <!-- 리스트 검색 -->
    <dd>
     <s:select name="searchWhere" list="#{'total':'전체검색','localName':'현지업체명','headName':'본사업체명','DESK103':'업체관리번호'}"/> 
    </dd>
    <dd>
    	<input type="text" name="searchKeyword" id="searchKeyword" style="width:140px;height:20px" value="<s:property value="searchKeyword"/>" />
    </dd>
    <dd><img src="/images/business/btn_search.gif" id="btn_saerch_bizInfo" alt="검색하기" width="83" height="24" border="0" style="cursor:pointer"/></dd>
    <dd style="width:150px; padding-left:50px;">
    	<label for="state">정렬 : </label>
        	<s:select name="order" id="orderBy"  list="#{'regTime':'등록일▼','regTime2':'등록일▲','localName':'현지업체명','headName':'본사업체명' }"/>
    </dd>
    <dd class="SubContents_ExcelDown"><img src="/images/business/btn_ExelDown.gif" id="btn_excel_download" alt="엑셀다운로드" width="114" height="26" border="0" style="cursor:pointer"/></dd>
  </dl>
  <!-- 리스트 검색 -->
  <dl class="LIst_Zone"><!-- 리스트 -->
    <dd>
      <table cellspacing="0" border="1" summary="글목록" class="Listboard">
        <caption>글목록</caption>
        <colgroup>
			<col width="40px">
			<col width="178px">
			<col width="195px">
			<col width="130px">
			<col width="64px">
			<col width="95px">
		</colgroup>
        <thead>
          <tr>
            <th scope="col">번호</th>
            <th scope="col">현지 업체명</th>
            <th scope="col">본사 업체명</th>
            <th scope="col">현지 사업자번호</th>
            <th scope="col">담당자</th>            
          </tr>
        </thead>
        <tbody>
        <s:if test="companyList.size == 0">
     		<tr>
				<td colspan="6" align="center">등록된 기업이 없습니다.</td>
			</tr>
		</s:if>
        <s:else>
			<s:iterator value="companyList" status="stat">
	          <tr>
	            <td><a href="/biz/bizDetail.desk?companySeq=<s:property value="companySeq"/>"><s:property value="(#totalCount + 1 - ((pageInfoDataMap.pageNumber - 1) * pageInfoDataMap.countPerPage)) - (#stat.count)"/></a></td>
	            <td style="text-align:left;text-indent:15px"><s:property value="localName"/></td>
	            <td style="text-align:left;text-indent:15px"><s:property value="headName"/></td>
	            <td><s:property value="localBizNo"/></td>
	            <td>
	            	<!-- 다수의 담당자를 가져옴. -->
	            	<c:choose>
	            		<c:when	 test="${not empty bizCustomerInfoBean}">
							<s:select name="customerName" list="bizCustomerInfoBean" listKey="customerSeq" listValue="customerName"/>
						</c:when>
						<c:otherwise>
							-
						</c:otherwise>
					</c:choose>
	            </td>            
	          </tr>
         	</s:iterator>
         </s:else>
        </tbody>
        <!-- 리스트 부분 -->
      </table>
    </dd>
  </dl><!-- 리스트 -->
  <dl class="List_Page_area"><!-- 리스트 페이징 부분 -->
    <dd class="page_area">
      <div class="paginate">
      	<s:if test="pageInfoDataMap.startPage > pageInfoDataMap.pagePerBlock">
			<s:a href="%{bizListURLPrev}" cssClass="pre">이전페이지</s:a>
		</s:if> 
      	<c:forEach var="pageNum" begin="${pageInfoDataMap.startPage}" end="${pageInfoDataMap.endPage}">
      		<input type="hidden" id="pageNum" value="${pageNum}"/>
      		<input type="hidden" id="deskCode" value="${deskCode }"/>
      		<input type="hidden" id="order" value="${order }"/>
			<c:choose>
				<c:when test="${pageNum == pageInfoDataMap.pageNumber}">
					${pageNum} 
				</c:when>
				<c:when test="${pageNum == 0 }">
				
				</c:when>
				<c:otherwise>
					<a href="<c:url value="/biz/bizListForUser.desk?pageNumber=${pageNum}&deskCode=${deskCode}&order=${order }"/>"> [${pageNum}] </a>
				</c:otherwise>
			</c:choose>
		</c:forEach>
      	<s:if test="pageInfoDataMap.endPage < pageInfoDataMap.totalPageCount">
			<s:a href="%{bizListURLNext}" cssClass="next">다음페이지 </s:a>
		</s:if>				
	</div>
    </dd>
  </dl><!-- 리스트 페이징 부분 -->
  <dl class="List_Btn_area"><!-- 버튼 부분 -->
    <dd class="Left_Zone"><a href="/biz/bizListForUser.desk"><img src="/images/notice/btn_list.gif" alt="목록" width="52" height="26" border="0" /></a></dd>
    <s:if test="#authCode != 'ADMIN'"> <%// 관리자는 등록을 하지 않는다. 해당 센터의 담당자만 등록할 수 있다 %>
    	<dd class="Right_Zone"><a href="/biz/bizForm.desk"><img src="/images/business/btn_write.gif" width="113" height="26" alt="기업정보 등록" /></a></dd>
    </s:if>
  </dl><!-- 버튼 부분 --> 
</div>
